﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition;
using System.IO;

namespace Steve.TestHelper
{
    [Export(typeof(CategoryRepository))]
    public class StubCategoryRepository : CategoryRepository
    {
        public static Dictionary<string, Category> _cats = new Dictionary<string, Category>();

        static StubCategoryRepository()
        {
            AddCategory("dmp");
            AddCategory("dsp");
            AddCategory("month-1");
        }

        public static void Clear()
        {
            _cats.Clear();
        }

        public static Category AddCategory(string name, decimal weight = 1)
        {
            var cat = new Category()
            {
                CategoryName = name,
                RelevancyWeight = weight
            };

            _cats[name] = cat;

            return cat;
        }

        protected override IEnumerable<Category> GetCategoriesCore()
        {
            return _cats.Values;
        }

        protected override Category SaveCategoryCore(Category toSave)
        {
            _cats[toSave.CategoryName] = toSave;

            return toSave;
        }
    }
}
